# import time
# from selenium import webdriver
#
# driver = webdriver.Chrome()
# driver.maximize_window()
# driver.get("https://kns.cnki.net/kns8s/defaultresult/index?korder=&kw=")
# time.sleep(3)
# driver.find_element("xpath", "//input[@id='txt_search']").send_keys("爬虫")
# driver.find_element("xpath", "//input[@class='search-btn']").click()
# time.sleep(5)
#
# tr_list = driver.find_elements("xpath", "//table[@class='result-table-list']/tbody/tr")
# for tr in tr_list:
#     data = [td.text for td in tr.find_elements("xpath", ".//td")]
#     print(data)

# a_list = driver.find_elements("xpath", "//td[@class='name']/a[@class='fz14']")
# for a in a_list:
#     a.click()
#     time.sleep(5)
#     # 标签页切换
#     driver.switch_to.window(driver.window_handles[1])
#     category_id = driver.find_element("xpath","//div[@class='wx-tit']/h1").text
#     print("论文详情页分类号",category_id)
#     # 标签页关闭
#     driver.close()
#     driver.switch_to.window(driver.window_handles[0])
#     # driver.quit()



# 页面的前进后退
from selenium import webdriver
from time import sleep

driver = webdriver.Chrome()
driver.get("https://www.baidu.com/s?wd=bilibili&pn=0")
sleep(5)
driver.get("https://www.baidu.com/s?wd=bilibili&pn=10")
sleep(5)
driver.get("https://www.baidu.com/s?wd=bilibili&pn=20")
sleep(5)

driver.back()
sleep(5)
driver.back()  # 标签页后退
sleep(5)
driver.forward()
sleep(5)
driver.forward() # 标签页前进

driver.refresh()# F5 当前标签页刷新